/*!
 * \file Main.cpp
 *
 * ONLY FOR DEBUG & TESTING PURPOSES! IS NOT A PART OF LIBRARY!
 */

// TODO: Add a AudioStream class
// TODO: Add a VideoStream class
// TODO: Add a Networking class
// TODO: Add support for Blending

#include "WrapAll.hpp"

using namespace wa;

int main ( )
{
  try
  {
    Setup::SetupAll( "Setup.xml" );

    wa::PointGfx<float> v1( 50, 50 );
    wa::PointGfx<float> v2( 50, 50 );

    wa::LineGfx<float> l1( 100, 100, 50, 200 );
    wa::LineGfx<float> l2( 100, 80, 200, 100 );

    wa::RectangleGfx<float> r1( 300, 300, 200, 100, wa::OUTLINED );
    wa::RectangleGfx<float> r2( 300, 300, 150, 100, wa::OUTLINED );

    wa::Log::Write( "New Animation!" );
    wa::Animation a( "gfx/anim/bullet*.bmp", 100, wa::LOOPED, wa::MASKED );
    wa::Log::Write( "Created" );

    while ( !key[ KEY_ESC ] )
    {
      if ( Updater::UpdateNeeded() )
      {
        Keyboard::Update();
        Mouse::Update();

        if ( wa::Keyboard::IsHeld( KEY_RIGHT ) )
          v1.Move( wa::DIRECTION_RIGHT );

        a.Update();
      }

      Renderer::NewFrame();
      {
        a.Render( 120, 120 );
        v1.Render();
      }
      Renderer::CloseFrame();
    }

    wa::ResourceManager::CollectGarbage();

    Setup::ClearAll();
  }

  catch ( std::exception& e )
  {
    wa::Log::Error( "%s", e.what() );
  }

  catch ( ... )
  {
    wa::Log::Error( "Unknown exception catched!" );
  }

  return 0;
}
END_OF_MAIN ()
